import {Injectable} from '@angular/core';
import {BaseHttpService} from '../base-http.service';
import {Observable} from 'rxjs';

export interface UserQuestionTestDto {
  passFlag: boolean;
  questionTestId: number;
  score: number;
  startTime: number;
  useTime: number;
  userId: number;
  wrongQuestionId: number[];
}

export interface StartExamModel {
  id?: number;
  passScore: number;
  judgeScore: number;
  multiScore: number;
  omitScore: number;
  duration: number;
  questionVos: ExamAnswer[];
  radioScore: number;
}

export interface ExamAnswer {
  content: string;
  id: number;
  pictureUrl: string;
  questionOptionVos: OptionsAnswer[];
  type: number;
}

export interface OptionsAnswer {
  answerFlag: boolean;
  content: string;
  id: number;
  pictureUrl: string;
  sort: string;
}

@Injectable({
  providedIn: 'root'
})
export class StartExamService {

  constructor(public http: BaseHttpService) {
  }


  public getStartExam(id: number): Observable<StartExamModel> {
    return this.http.get(`/start-question-test/${id}`);
  }


  public getEndExam(params: UserQuestionTestDto): Observable<UserQuestionTestDto[]> {
    return this.http.post('/end-question-test', params);
  }


}
